bitkeeper revision 1.1741 (42ba8952xTiiA50azru9j4tKvXIVDA)
authorarun.sharma@intel.com[kaf24] <arun.sharma@intel.com[kaf24]>
Thu, 23 Jun 2005 10:05:06 +0000 (10:05 +0000)
committerarun.sharma@intel.com[kaf24] <arun.sharma@intel.com[kaf24]>
Thu, 23 Jun 2005 10:05:06 +0000 (10:05 +0000)
[PATCH] vmx-gdbserver-paging.patch

gdbserver should not try to convert guest physical to machine physical if
paging is not enabled.

Signed-off-by: Arun Sharma <arun.sharma@intel.com>
tools/libxc/xc_ptrace.c
xen/arch/x86/dom0_ops.c
xen/include/public/arch-x86_32.h

index 1db45a7bbb5bfb18b910154a0cff10d9542f273c..a8b39a648d85896bc5d50f5e35ffc39a60ae4617 100644 (file)
@@ -3,6 +3,8 @@
 #include "xc_private.h"
 #include <time.h>
 
+#define X86_CR0_PE              0x00000001 /* Enable Protected Mode    (RW) */
+#define X86_CR0_PG              0x80000000 /* Paging                   (RW) */
 
 #define BSD_PAGE_MASK  (PAGE_SIZE-1)
 #define        PG_FRAME        (~((unsigned long)BSD_PAGE_MASK)
@@ -132,6 +134,13 @@ static int                      regs_valid[MAX_VIRT_CPUS];
 static unsigned long            cr3[MAX_VIRT_CPUS];
 static vcpu_guest_context_t ctxt[MAX_VIRT_CPUS];
 
+static inline int paging_enabled(vcpu_guest_context_t *v)
+{
+    unsigned long cr0 = v->cr0;
+
+    return (cr0 & X86_CR0_PE) && (cr0 & X86_CR0_PG);
+}
+
 /* --------------------- */
 
 static void *
@@ -179,7 +188,7 @@ map_domain_va(unsigned long domid, int cpu, void * guest_va, int perm)
     } 
     if ((pde = cr3_virt[cpu][vtopdi(va)]) == 0) /* logical address */
        goto error_out;
-    if (ctxt[cpu].flags & VGCF_VMX_GUEST)
+    if ((ctxt[cpu].flags & VGCF_VMX_GUEST) && paging_enabled(&ctxt[cpu]))
         pde = page_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
     if (pde != pde_phys[cpu]) 
     {
index 2a269f11b6e7d7b36f4f597109d46253d1549e38..fdefebd4b6917a19ef76573e77e2e502117f23ef 100644 (file)
@@ -393,8 +393,11 @@ void arch_getdomaininfo_ctxt(
 
 #ifdef __i386__
 #ifdef CONFIG_VMX
-    if ( VMX_DOMAIN(v) )
+    if ( VMX_DOMAIN(v) ) {
         save_vmx_cpu_user_regs(&c->user_regs);
+        __vmread(CR0_READ_SHADOW, &c->cr0);
+        __vmread(CR4_READ_SHADOW, &c->cr4);
+    }
 #endif
 #endif
 
index 1a11a3be86dafc0b454a6169dda450d255bc47aa..44bc8dd46ff1341e69390fd6e8c1cd5c856669e1 100644 (file)
@@ -137,6 +137,8 @@ typedef struct vcpu_guest_context {
     unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
     unsigned long kernel_ss, kernel_sp;     /* Virtual TSS (only SS1/SP1)   */
     unsigned long pt_base;                  /* CR3 (pagetable base)         */
+    unsigned long cr0;                      /* CR0                          */
+    unsigned long cr4;                      /* CR4                          */
     unsigned long debugreg[8];              /* DB0-DB7 (debug registers)    */
     unsigned long event_callback_cs;        /* CS:EIP of event callback     */
     unsigned long event_callback_eip;